<template>
  <div class="empty-page">
    <el-empty :description="description">
      <template #image>
        <el-icon class="empty-icon" :size="80">
          <component :is="icon" />
        </el-icon>
      </template>
      <template #description>
        <h3>{{ title }}</h3>
        <p>{{ description }}</p>
      </template>
      <el-button type="primary" @click="handleAction" v-if="actionText">
        {{ actionText }}
      </el-button>
    </el-empty>
  </div>
</template>

<script setup lang="ts">
import { Component } from 'vue'
import { Construction } from '@element-plus/icons-vue'

interface Props {
  title?: string
  description?: string
  icon?: Component
  actionText?: string
  onAction?: () => void
}

const props = withDefaults(defineProps<Props>(), {
  title: '功能开发中',
  description: '该功能正在开发中，敬请期待...',
  icon: Construction,
  actionText: '',
  onAction: undefined
})

const handleAction = () => {
  if (props.onAction) {
    props.onAction()
  }
}
</script>

<style scoped lang="scss">
.empty-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: 40px;

  .empty-icon {
    color: #d1d5db;
  }

  :deep(.el-empty__description) {
    h3 {
      margin: 16px 0 8px 0;
      color: #374151;
      font-size: 18px;
    }

    p {
      margin: 0;
      color: #6b7280;
      font-size: 14px;
    }
  }
}
</style>
